<?php
/**
 * CreateUser: zlh
 * CreateTime: 2022/2/2 15:13
 * Remark:
 */

namespace App\Models\Auth;

use App\Consts\TableConsts\TableConsts;
use App\Models\BaseModel;

class AuthMenuModel extends BaseModel
{
    protected $table = TableConsts::CY_AUTH_MENU_TABLE_NAME;

    protected $primaryKey = TableConsts::CY_AUTH_MENU_TABLE_PRIMARY_KEY;

    protected $fillable = [
        'menu_id',
        'menu_name',
        'menu_url',
        'menu_parent_id',
    ];

    public $timestamps = false;

    /**
     * 获取菜单
     * @param $companyId
     * @param string[] $select
     * @return mixed
     */
    public function getAuthMenuMenu($select = ["*"]){
        return $this->select($select)->get();
    }




    public function getAuthMenuInfoByAuthMenuIds($authMenuIds , $select = ["*"]){
        return $this->whereIn('menu_id',$authMenuIds)->select($select)->get();
    }

    public function isExistByCondition($conditionData){
        return $this->withoutGlobalScopes()
            ->firstOrnew($conditionData)->exists;
    }

}